 //
//  BMKCustomPaoPaoView.m
//  Shengzhuli
//
//  Created by FXGuo on 2018/2/2.
//  Copyright © 2018年 kamangkeji. All rights reserved.
//

#import "BMKCustomPaoPaoView.h"

#define kArrorHeight 10
@interface BMKCustomPaoPaoView()

@property (nonatomic,weak) UILabel *textLab;
@end

@implementation BMKCustomPaoPaoView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor clearColor];
//        UIView *cView = [[UIView alloc]init];
//        [self addSubview:cView];
//
//        UILabel *lab = [[UILabel alloc]init];
//        lab.font = Font(15);
//        lab.textColor = [UIColor whiteColor];
//        lab.layer.cornerRadius = 5.0;
//        lab.clipsToBounds = YES;
//        lab.textAlignment = NSTextAlignmentCenter;
//        lab.backgroundColor = RGBA(0, 0, 0, 0.8);
//        self.textLab = lab;
        
    }
    return self;
}

- (void)drawRect:(CGRect)rect
{
    [self drawInContext:UIGraphicsGetCurrentContext()];
    
    self.layer.shadowColor = [[UIColor blackColor] CGColor];
    self.layer.shadowOpacity = 1.0;
    self.layer.shadowOffset = CGSizeMake(0.0f, 0.0f);
}

- (void)drawInContext:(CGContextRef)context
{
    CGContextSetLineWidth(context, 2.0);
    CGContextSetFillColorWithColor(context, RGBA(0, 0, 0, 0.6).CGColor);
    
    [self getDrawPath:context];
    CGContextFillPath(context);
}

- (void)getDrawPath:(CGContextRef)context
{
    CGRect rrect = self.bounds;
    CGFloat radius = 6.0;
    CGFloat minx = CGRectGetMinX(rrect),
    midx = CGRectGetMidX(rrect),
    maxx = CGRectGetMaxX(rrect);
    CGFloat miny = CGRectGetMinY(rrect),
    maxy = CGRectGetMaxY(rrect)-kArrorHeight;
    
    CGContextMoveToPoint(context, midx+kArrorHeight, maxy);
    CGContextAddLineToPoint(context,midx, maxy+kArrorHeight);
    CGContextAddLineToPoint(context,midx-kArrorHeight, maxy);
    
    CGContextAddArcToPoint(context, minx, maxy, minx, miny, radius);
    CGContextAddArcToPoint(context, minx, minx, maxx, miny, radius);
    CGContextAddArcToPoint(context, maxx, miny, maxx, maxx, radius);
    CGContextAddArcToPoint(context, maxx, maxy, midx, maxy, radius);
    CGContextClosePath(context);
}

@end
